<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta name="description" content="">
	<title>{BEESCRM:$data.name}</title>
	<link href="/assets/activity/disc/css/activity-style.css" rel="stylesheet" type="text/css">
	<link href="/assets/activity/disc/css/notice.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/assets/activity/disc/js/jquery.js"></script>
	<script type="text/javascript" src="/assets/activity/disc/js/notice.js"></script>
	<style>
		a{ display:block;font-size:15px;line-height:18px;text-decoration:none;color:#333;font-family:Arial;font-size:12px;}
		#maq{
		width:100%;
		height:64px;
		overflow:hidden;
		}
		.div1 a{width:90%; height:18px; }
		.div2 a{ width:90%;}
		.div1 a p{ float:left; width:90px; margin-left:8%; margin-right:2%;}
		.div2 a p{width:90px; margin-left:8%; margin-right:2%;}
		.footFix {
			width: 100%;
			text-align: center;
			position: fixed;
			left: 0;
			bottom: 0;
			z-index: 99;
		}
		#footReturn a, #footReturn2 a {
			display: block;
			line-height: 41px;
			color: #fff;
			text-shadow: 1px 1px #282828;
			font-size: 14px;
			font-weight: bold;
		}
		#footReturn, #footReturn2 {
			z-index: 89;
			display: inline-block;
			text-align: center;
			text-decoration: none;
			vertical-align: middle;
			cursor: pointer;
			width: 100%;
			outline: 0 none;
			overflow: visible; Unknown property name.-moz-box-sizing : border-box;
			box-sizing: border-box;
			padding: 0;
			height: 41px;
			opacity: .95;
			border-top: 1px solid #181818;
			box-shadow: inset 0 1px 2px #b6b6b6;
			background-color: #515151; 
			Invalid property value.background-image :-ms-linear-gradient( top, #838383, #202020);
			background-image: -webkit-linear-gradient(top, #838383, #202020);
			Invalid property value.background-image : -moz-linear-gradient( top,#838383, #202020); 
			Invalid property value.background-image :-o-linear-gradient( top, #838383, #202020);
			background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#838383),to(#202020));
			Invalid property value.filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#838383',endColorstr='#202020');
			Unknown property name.-ms-filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#838383',endColorstr='#202020');
		}
	</style>
</head>
<body class="activity-lottery-winning">
	<div class="main">
		<if condition="$data['end'] eq 1">
			<div class="activity-lottery-end">
				<div class="main">
					<div class="banner">
						<img src="{BEESCRM:$data.end_pic}" />
					</div>
					<div class="content" style="margin-top: 10px">
						<div class="boxcontent boxyellow">
							<div class="box">
								<div class="title-red">活动结束说明：</div>
								<div class="Detail">
									<p>{BEESCRM:$data.end_tips}</p>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		<elseif condition="$data.end eq 2"/>
			<div class="activity-lottery-end">
				<div class="main">
					<div class="banner">
						<img src="{BEESCRM:$data.start_pic}" />
					</div>
					<div class="content" style="margin-top: 10px">
						<div class="boxcontent boxyellow">
							<div class="box">
								<div class="title-red">活动说明：</div>
								<div class="Detail">
									<p>活动时间:{BEESCRM:$data.start_time|date='Y-m-d',###}至{BEESCRM:$data.end_time|date='Y-m-d',###}</p>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		<else />
			<div id="outercont">
				<div id="outer-cont">
					<div id="outer">
						<img src="/assets/activity/disc/images/activity-lottery-5.png">
					</div>
				</div>
				<div id="inner-cont">
					<div id="inner">
						<img src="/assets/activity/disc/images/activity-lottery-2.png">
					</div>
				</div>
			</div>
		<div class="content">
			<img class="hengfu" src="/assets/activity/disc/images/hengfu.png">
			<div class="boxcontent boxyellow" id="result" style="display: none">
				<div class="box">
					<div class="title">
						<span>恭喜您中奖啦~</span>
					</div>
					<div class="Detail">
						<p>
							你中了：<span class="red" id="prizetype"> </span>
						</p>
						<p class="red" id="red"></p>
						<p id='register_1' style="display:none;">
							<input type="hidden" id="log_id" >
							<input name="" class="px" id="wechat_name" value="{BEESCRM:$data['user_log'][0]['wechat_name']}" type="text" placeholder="请输入您的微信号">
							<input name="" class="px" id="username" value="{BEESCRM:$data['user_log'][0]['username']}" type="text" placeholder="请输入您的姓名">
							<input name="" class="px" id="mobile" value="{BEESCRM:$data['user_log'][0]['mobile']}" type="text" placeholder="请输入您的手机号">
						</p>
						<p id='register_2' style="display:none;">
							<input class="pxbtn" name="提 交" id="save-btn" type="button" value="用户提交">
						</p>
					</div>
				</div>
			</div>

			<if condition="$data['end'] eq 5">
			<div class="main">
				<div class="content" style="margin-top: 10px">
					<div class="boxcontent">
						<div class="box">
							<div class="title-red">恭喜:</div>
							<div class="Detail">
								<p>
									尊敬的:<font color='red'>{BEESCRM:$data.uname} </font>,您已经中了
										<font color='red'> {BEESCRM:$data.prize} </font>请您尽快与我们联系
								</p>
							</div>
						</div>
					</div>
				</div>
			</div>
			</if>
			
			<div class="boxcontent">
				<div class="box">
					<div class="title">
						<span>奖项设置：</span>
					</div>
					<div class="Detail">
						<p>
							每人默认抽奖次数:{BEESCRM:$data.default_num}<br>
							<span id='xshow' > 您还有 
							<span class="red" id="usenums">{BEESCRM:$data.overplus}</span> 次抽奖机会</span>
						</p>
						<volist name="data.prize" id="vo">
						<p>{BEESCRM:$vo.grade_name}: {BEESCRM:$vo.name}</p><input type="hidden" id="grade{BEESCRM:$vo.grade}" value="{BEESCRM:$vo.name}">
						</volist>
					</div>
				</div>
			</div>
			<div class="boxcontent">
				<div class="box">
					<div class="title">
						<span>中奖详情：</span>
					</div>
					<div class="Detail">
						<div id="maq" >
							<div class="div1"  id="mtext" >
								<volist name="data.all_log" id="vo">
									<a href="javascript:">
										<span style="margin-left:10px;">{BEESCRM:$vo['log_name']}</span>
										<span style="margin-left:50px;">{BEESCRM:$vo['name']}</span>
									</a>
								</volist>
							</div>
							<div id="m0" class="div2" ></div>
						</div>
					</div>
				</div>
			</div>
			<div class="boxcontent">
				<div class="box">
					<div class="title">活动说明：</div>
					<div class="Detail">
						<p>{BEESCRM:$data.description}</p>
						<p>活动时间:{BEESCRM:$data.start_time|date='Y-m-d',###}至{BEESCRM:$data.end_time|date='Y-m-d',###}</p>
					</div>
				</div>
			</div>
			<div class="boxcontent" >
				<div class="box">
					<div class="title">
						<span>中奖记录</span>
					</div>
					<div id='append'>
					<volist name='data.user_log' id='vo'>
						<div class="Detail">
							<p>你中了：<span class="red">{BEESCRM:$vo['name']}</span></p>
							<p>中奖时间：{BEESCRM:$vo['create_time']|date='Y-m-d H:i:s',###}</p>
						</div>
					</volist>
					</div>
				</div>
			</div>
		</div>
		</if>
	</div>
	<div style="height: 20px;"></div>
	<script src="/assets/activity/disc/js/jquery.js" type="text/javascript"></script>
	<script src="/assets/activity/disc/js/alert.js" type="text/javascript"></script>
	<script type="text/javascript">
		/* var speed=80 //调整滚动速度
		m0.innerHTML=mtext.innerHTML;
		function Marquee(){
		if(m0.offsetTop-maq.scrollTop<=0)
		maq.scrollTop-=mtext.offsetHeight
		else{
		maq.scrollTop++
		}
		} */
		var speed=80; //调整滚动速度
		m0.innerHTML=mtext.innerHTML;
		function Marquee(){
			if(m0.offsetHeight-maq.scrollTop<=0){//
					maq.scrollTop -= m0.offsetHeight;
			}else{
				//alert(maq.scrollTop);
				maq.scrollTop++;
					
			}
		}
		var MyMar=setInterval(Marquee,speed)
		/* maq.onmouseover=function() {clearInterval(MyMar)}
		maq.onmouseout=function() {MyMar=setInterval(Marquee,speed)} */
	</script>
	<script type="text/javascript">
$(function() {
    window.requestAnimFrame = (function() {
        return window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        function(callback) {
            window.setTimeout(callback, 1000 / 60)
        }
    })();

    var totalDeg = 360 * 3 + 0;
    var steps = []; 
    var lostDeg = [36, 96, 156, 216, 276,336];
    var prizeDeg = [6, 66, 126,186,246,306];
    var prize, sncode;
	var usenums = 0;
    var count = 0; 
    var now = 0;
    var a = 0.01;
    var outter, inner, timer, running = false;

    function countSteps() {
        var t = Math.sqrt(2 * totalDeg / a);
        var v = a * t;
        for (var i = 0; i < t; i++) {
            steps.push((2 * v * i - a * i * i) / 2)
        }
        steps.push(totalDeg)
    }
     
    function step() {
        outter.style.webkitTransform = 'rotate(' + steps[now++] + 'deg)';
        outter.style.MozTransform = 'rotate(' + steps[now++] + 'deg)';
        if (now < steps.length) { 
            running = true;
            requestAnimFrame(step) 
        } else { 
            running = false;            
             
            setTimeout(function() {
                if (prize != null) {  //中奖
                	var a=$("#grade1").val();
                	var b=$("#grade2").val();
                	var c=$("#grade3").val();
                	var d=$("#grade4").val();
                	var e=$("#grade5").val();
                	var f=$("#grade6").val();
                    var type = "";
                    if (prize == "一等奖") {
                        type = "一等奖  "+a
                    } else if (prize == "二等奖") {
                        type = "二等奖   "+b
                    } else if (prize == "三等奖") {
                        type = "三等奖   "+c
                    }
                    else if (prize == "四等奖") {
                        type = "四等奖   ~"+d
                    }
                    else if (prize == "五等奖") {
                        type = "五等奖   "+e
                    }
                    else if (prize == "六等奖") {
                        type = "六等奖   "+f
                    }
                    $("#prizetype").text(type);
                    $("#winprize").val(type);
                    $("#result").slideToggle(500);  
                    /* $("#outercont").slideUp(500) */
                } else { //不中奖
                    alert("不要灰心哦~敢问奖在何方，奖就在手指下！再转一次吧。")
                }
            }, 200)
        } //if
    } //setps()
    
    function start(deg) {
        deg = deg || lostDeg[parseInt(lostDeg.length * Math.random())];
        running = true;
        clearInterval(timer);
        totalDeg = 360 * 5 + deg;
        steps = [];
        now = 0;
        countSteps();
        //$('#result').slideUp(600);
        requestAnimFrame(step)
    }
    
    window.start = start;
    outter = document.getElementById('outer'); 
    inner = document.getElementById('inner'); 
    i = 10;
    var register=1;
    var end = 0;
    var from="{BEESCRM:$from}";
    $("#inner").click(function() {
		if(from==1){
			alert('请先关注公众号');
			return;
		}
        if (running) return;
		if($('#register_1').is(':visible')){
			alert('请先填写信息');
			return;
		}
        if (count >= {BEESCRM:$data.overplus}) {
            alert("Oh~No~您已经抽了{BEESCRM:$data.num} 次奖,不能再抽了,改天再来吧!");
            return
        }

       /*  if (prize != null) {
            alert("亲，你不能再参加本次活动了喔！下次再来吧^_^");
            return
        } */
        $("#result").hide("slow");
       $.ajax({
			url: "/Activity/Disc/getajax",
			dataType: "json",
			type: "POST",
			data: {
				act_id  : "{BEESCRM:$data.disc_id}",
			},
         beforeSend : function(){
            running = true;
            timer = setInterval(function() {
                i += 5;
                outter.style.webkitTransform = 'rotate(' + i + 'deg)';
                outter.style.MozTransform = 'rotate(' + i + 'deg)'
            },1)
         },
		success: function(backdata){
            if (backdata.norun == 1) {      
                    alert(backdata.msg);
                    count = 5; //原来是 5 
                    clearInterval(timer);
                    return
            }
            if (backdata.norun == 2) {  
                    alert("您已经抽了"+backdata.canrqnums+"次奖,不能再抽了,下次再来吧!");
                    count = backdata.canrqnums;
                    clearInterval(timer);
                    return
            }
            if (backdata.norun == 3) {
                    alert("请您向公众平台发送抽奖指令，参与抽奖!");
                    clearInterval(timer);
                    return
            }
            if (backdata.success) { 
                prize = backdata.prizetype;
                xregister = backdata.register;
                if(xregister!=1){
                	$('#register_1').show();
                	$('#register_2').show();
                	register=0;
                }
                var n=parseInt($('#usenums').text())-1;
                $('#usenums').text(n);
                var point=100;
                var points=$('#point').text();
                var num;
                if(points>point){
                	num=points-point;
                }else{
                	num=0;
                }
                
                $('#point').text(num);
                 if(prize!=0){
                    start(prizeDeg[backdata.prizetype - 1]);
                    if(prize==5){
                    	prize='五等奖';
                    }else if(prize==4){
                    	prize='四等奖';
                    }else if(prize==3){
                    	prize='三等奖';
                    }else if(prize==2){
                    	prize='二等奖';
                    }else if(prize==1){
                    	prize='一等奖';
                    }else if(prize==6){
                    	prize='六等奖';
                    }
                    var date=getNowFormatDate();
                    var html='<div class="Detail" style="border-style:dotted ;margin-top:5px;margin-left:5px;margin-right:5px;"><p>';
                    html+='你中了：<span class="red">'+backdata.prize_name+'</span></p>';
                    html+='<p>中奖时间：'+date+'</p></div>';
                    log_id=backdata.log_id;
                    $('#log_id').val(log_id);
                    $('#append').prepend(html);
                 }else{
                    prize = null;
					start()
                }
        		$('#xshow').show();
            } else {

                    prize = null;
                    var n=parseInt($('#usenums').text())-1;
                    $('#usenums').text(n);
                    start()
            }
            running = false;
            count++;
         },
         error      : function(){
                prize = null;
				usenums=backdata.usenums;
                start();
                running = false;
                count++;
         },
         complete   : function(XMLHttpRequest, textStatus){
            //console.log('当请求完成之后调用这个函数，无论成功或失败.  请求类型:'+textStatus);  
         },
         timeout    : 3000       
        
       })//ajax
    }) //#inner click function;
});

function getNowFormatDate()
{
    var day = new Date();
    var Year = 0;
    var Month = 0;
    var Day = 0;
    var CurrentDate = "";
    //初始化时间
    //Year= day.getYear();//有火狐下2008年显示108的bug
    Year= day.getFullYear();//ie火狐下都可以
    Month= day.getMonth()+1;
    Day = day.getDate();
    Hour = day.getHours();
    Minute = day.getMinutes();
    Second = day.getSeconds();
    CurrentDate += Year + "-";
    if (Month >= 10 )
    {
    	CurrentDate += Month + "-";
    }
    else
    {
    	CurrentDate += "0" + Month + "-";
    }
    if (Day >= 10 )
    {
    	CurrentDate += Day ;
    }
    else
    {
    	CurrentDate += "0" + Day ;
    }
    if(Hour<10){
    	Hour='0'+Hour;
    }
    if(Minute<10){
    	Minute='0'+Minute;
    }
    if(Second<10){
    	Second='0'+Second;
    }
    CurrentDate += ' '+Hour+':'+Minute+':'+Second;
    return CurrentDate;
} 

//中奖提交
$("#save-btn").bind("click",
function() {
    var btn = $(this);
    var mobile = $("#mobile").val();
    var username  = $("#username").val();
    var wechat_name  = $("#wechat_name").val();
    var log_id=$('#log_id').val();
    var verify_method=/1[3-8]+\d{9}/;
    if (mobile == '') {
        alert("请填写手机号");
        return
    }
    if (username == '') {
        alert("请填写您的姓名");
        return
    }else if (!verify_method.test(mobile)) {
    	 alert("请填写正确的手机号");
    	 return;
    }else if(wechat_name==''){
    	alert('请填写您的微信号');
    	return;
    }
   
    var submitData = {
        mobile: mobile,
        act_id  : "{BEESCRM:$data.disc_id}",
        username: username,
        wechat_name:wechat_name,
        id:log_id,
    };
    $.post('/Activity/Disc/add', submitData,
    function(data) {
        if (data.success == true) {
        	$('#register_1').hide();
        	$('#register_2').hide();
            alert(data.msg);
            $("#result").hide("slow");
            /* $("#outercont").slideDown(500); */
            return
        } else {}
    },
    "json")
});
</script>
</body>
</html>